const API_BASE_URL = 'http://localhost:3888';

async function testProductAPI() {
  try {
    console.log('开始测试产品API...\n');

    // 1. 测试获取产品分类
    console.log('1. 测试获取产品分类...');
    const categoriesResponse = await fetch(`${API_BASE_URL}/api/web/product-categories`);
    const categoriesData = await categoriesResponse.json();
    console.log('产品分类:', categoriesData);
    console.log('');

    // 2. 测试获取产品列表
    console.log('2. 测试获取产品列表...');
    const productsResponse = await fetch(`${API_BASE_URL}/api/web/products`);
    const productsData = await productsResponse.json();
    console.log('产品列表:', productsData);
    console.log('');

    // 3. 测试获取推荐产品
    console.log('3. 测试获取推荐产品...');
    const recommendResponse = await fetch(`${API_BASE_URL}/api/web/products/recommend`);
    const recommendData = await recommendResponse.json();
    console.log('推荐产品:', recommendData);
    console.log('');

    // 4. 测试获取置顶产品
    console.log('4. 测试获取置顶产品...');
    const topResponse = await fetch(`${API_BASE_URL}/api/web/products/top`);
    const topData = await topResponse.json();
    console.log('置顶产品:', topData);
    console.log('');

    console.log('✅ 所有API测试完成！');

  } catch (error) {
    console.error('❌ API测试失败:', error);
  }
}

testProductAPI(); 